home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
bmpkit
/
bmpkit.frm
< prev
next >
Wrap
Text File
|
1995-05-08
|
11KB
|
387 lines
VERSION 2.00
Begin Form Form1
Caption = "Form1"
ClientHeight = 4020
ClientLeft = 1125
ClientTop = 2010
ClientWidth = 7365
Height = 4425
Left = 1065
LinkMode = 1 'Source
LinkTopic = "Form1"
ScaleHeight = 2.792
ScaleMode = 5 'Inch
ScaleWidth = 5.115
Top = 1665
Width = 7485
Begin CommandButton Command4
Caption = "Show Original "
Height = 375
Left = 5640
TabIndex = 12
Top = 3480
Width = 1335
End
Begin CommandButton Command5
Caption = "Hide Original"
Height = 375
Left = 5640
TabIndex = 13
Top = 3000
Width = 1335
End
Begin CommandButton Command3
Caption = "Print"
Height = 375
Left = 6480
TabIndex = 2
Top = 2520
Width = 735
End
Begin CommandButton Command2
Caption = "Display"
Height = 375
Left = 5640
TabIndex = 1
Top = 2520
Width = 735
End
Begin HScrollBar HScroll1
Height = 255
Left = 5160
TabIndex = 6
Top = 960
Width = 1215
End
Begin OptionButton Option2
Caption = "Size"
Height = 255
Left = 5160
TabIndex = 9
Top = 600
Width = 855
End
Begin PictureBox Picture2
AutoRedraw = -1 'True
Height = 1335
Left = 840
ScaleHeight = 0.906
ScaleMode = 5 'Inch
ScaleWidth = 0.906
TabIndex = 4
Top = 600
Width = 1335
End
Begin OptionButton Option1
Caption = "Move"
Height = 255
Left = 5160
TabIndex = 8
Top = 240
Width = 855
End
Begin VScrollBar VScroll1
Height = 1095
Left = 6480
TabIndex = 7
Top = 120
Width = 255
End
Begin CommandButton Command1
Caption = "Exit"
Height = 375
Left = 4080
TabIndex = 0
Top = 120
Width = 735
End
Begin PictureBox Picture1
AutoSize = -1 'True
Height = 495
Left = 120
ScaleHeight = 0.323
ScaleMode = 5 'Inch
ScaleWidth = 0.323
TabIndex = 3
Top = 120
Width = 495
End
Begin Label Label3
AutoSize = -1 'True
Height = 195
Left = 5160
TabIndex = 11
Top = 2160
Width = 75
End
Begin Label Label2
AutoSize = -1 'True
Height = 195
Left = 5160
TabIndex = 10
Top = 1800
Width = 75
End
Begin Label Label1
Alignment = 2 'Center
Caption = "Scaled Image"
Height = 255
Left = 840
TabIndex = 5
Top = 120
Width = 1335
End
End
Sub Command1_Click ()
End
End Sub
Sub command2_click ()
'Make sure we have valid scaling values
If scalex = 0 Then scalex = 1
If scaley = 0 Then scaley = 1
'Set picture2.width to match picture1, with scaling.
'The 3.14 divisor matches inch dimension with the
'640X480 screen dimensions. Change for other display
'adapters.
Picture2.width = (picture1.width / 3.14) * scalex
Picture2.height = (picture1.height / 3.14) * scaley
'*Set constants for GDI calls
Const NULL = 0&
Const SRCCOPY = &HCC0020
Const NEWFRAME = 1
Const pixel = 3
'*Display scaled version in Picture2
'*StretchBlt requires pixel coordinates.
picture1.scalemode = 3
Picture2.scalemode = 3
'Set Dimensions for Picture2
Picture2.scalewidth = picture1.scalewidth / 3.14 * scalex
Picture2.scaleheight = picture1.scaleheight / 3.14 * scaley
'*Do not change the order of these statements.
hMemoryDC% = CreateCompatibleDC(picture1.hDC)
hOldBitMap% = SelectObject(hMemoryDC%, picture1.Picture)
'Variables for the StretchBlt function:
'1. Source of image HMemeoryDC% -- set above from original picture
'2,3. Positioning on output object. Must be integer, in pixels.
'4,5. Width, height of output image. Here we use the values set above.
'6, Source of image...in this case the memory image set by CreateCompatibleDC% function
'7,8. Don't know. Set to 0 works just fine! Experiment and let me know.
'9,10. X/Y coordinates for how much of original to put in new object. You can use
'these values for cropping, if you like.
'11. SRCCOPY, as set in constants above. Change at own risk.
ApiError% = StretchBlt(Picture2.hDC, Int(Picture2.left), Int(Picture2.top), Picture2.scalewidth, Picture2.scaleheight, hMemoryDC%, 0, 0, picture1.scalewidth, picture1.scaleheight, SRCCOPY)
hOldBitMap% = SelectObject(hMemoryDC%, hOldBitMap%)
ApiError% = DeleteDC(hMemoryDC%)
Picture2.Refresh
'*Reset scalemodes to previous inch values
picture1.scalemode = 5
Picture2.scalemode = 5
End Sub
Sub Command3_Click ()
'* Print all items other than the image first.
printer.scalemode = 5
printer.currentx = 3
printer.currenty = 3
printer.Print "Hello"
printer.currenty = 4
printer.currentx = 1
printer.drawwidth = 5
printer.Line -Step(printer.currentx + 2, 0)
'*After printing all other elements include your BMP
'printing routine, as below.
'* Print Scaled Image
'*Make certain we have valid scaling values
If scalex = 0 Then scalex = 1
If scaley = 0 Then scaley = 1
'*Set GDI Constants
Const NULL = 0&
Const SRCCOPY = &HCC0020
Const NEWFRAME = 1
Const pixel = 3
'* StretchBlt requires pixel coordinates.
picture1.scalemode = pixel
printer.scalemode = pixel
'*First two variables are the x,y coordinates (in Pixels)
'for the placement of images on the printed page. Since the
'form's ScaleMode is 5 for inches, multiply by 300 to
'match the the current inch positions of Picture2 on
'the 300 DPI device.
'*Second pair of variables set the height and width of the
'graphic to match the pixel size of the original picture
'in the invisible Picture1 box.
printgraphicx% = Picture2.left * 300
printgraphicy% = Picture2.top * 300
printer.scalewidth = picture1.scalewidth * scalex
printer.scaleheight = picture1.scaleheight * scaley
'*Do not change the order of these statements.
hMemoryDC% = CreateCompatibleDC(picture1.hDC)
hOldBitMap% = SelectObject(hMemoryDC%, picture1.Picture)
'Variables for the StretchBlt function:
'1. Source of image HMemeoryDC% -- set above from original picture
'2,3. Positioning on output object. Must be integer, in pixels.
'4,5. Width, height of output image. Here we use the values set above.
'6, Source of image...in this case the memory image set by CreateCompatibleDC% function
'7,8. Don't know. Set to 0 works just fine! Experiment and let me know.
'9,10. X/Y coordinates for how much of original to put in new object. You can use
'these values for cropping, if you like.
'11. SRCCOPY, as set in constants above. Change at own risk.
ApiError% = StretchBlt(printer.hDC, printgraphicx%, printgraphicy%, printer.scalewidth, printer.scaleheight, hMemoryDC%, 0, 0, picture1.scalewidth, picture1.scaleheight, SRCCOPY)
hOldBitMap% = SelectObject(hMemoryDC%, hOldBitMap%)
ApiError% = DeleteDC(hMemory